﻿@model Model.Sys.RoleInfo
@using WebPortal.MvcExtension
@{
    ViewBag.Title = "编辑角色信息";
    Layout = "~/Views/Shared/_Main.cshtml";
}
@section Head{
    <style>
        #spaName
        {
            display: none;
        }
    </style>
    <script type="text/javascript">
        $(function () {
            if ('@Model.Name' == '系统管理员') {
                $("#Name").hide();
                $("#spaName").show();
            }
        });

        function btnSave_Click() {
            submitForm();
            //$("#ff").submit();
        }

        function btnClose_Click() {
            returnParent(null);
        }
        //----------提交数据 ----------------
        function submitForm() {

            if ($.trim($("#Name").val()) == "") {
                alert("角色名称不能为空！");
                return false;
            }

            if ($('#ff').form("validate")) {
                var postUrl = "/Role/UpDate";
                var postData = $(":input").serialize(); 
                $.ajax({
                    type: "POST",
                    async: true,
                    url: postUrl,
                    data: postData,
                    success: function (result) {
                        if (result.Message) {
                            if (result.Success == true) {
                                alert(result.Message);
                            }
                            else {
                                alert(result.Message);
                            }
                        } else
                            alert(result);
                    }
                });
            }
        }
        //----------提交数据 END----------------
    </script>
}
<div style="margin: 5px;">
    @{
        // 渲染输出列表
        var dataToolbar = new ViewDataDictionary();
        dataToolbar.Add("PanelTitle", "编辑角色");
        dataToolbar.Add("GridID", "DataGrid");
        dataToolbar.Add("ShowAddButton", false);
        dataToolbar.Add("ShowDeleteButton", false);
        dataToolbar.Add("ShowSaveButton", true);
        dataToolbar.Add("ShowOtherButton", false);
        dataToolbar.Add("ShowBackButton", false);
        dataToolbar.Add("ShowCloseButton", false);
        dataToolbar.Add("ShowPager", true);
        dataToolbar.Add("ShowLoading", true);
        @Html.Partial("_ToolBarPanel", dataToolbar);

                                                   var dataConfigToolbar = new ViewDataDictionary();
                                                   dataConfigToolbar.Add("PanelTitle", "配置访问权限");
    }
    @using (Html.BeginForm("UpDate", "Role", FormMethod.Post, new { id = "ff" }))
    {
        @Html.HiddenFor(model => model.Id)
        <table class="table_bg" style="width: 100%;" cellpadding="0" cellspacing="0">
            <tr>
                <td style="text-align: right; width: 100px;">
                    <span class="red">*</span>角色名称：
                </td>
                <td>
                    <span id="spaName">@Model.Name</span>
                    @Html.TextBoxFor(model => Model.Name, new { style = "Width: 400px;", maxlength = "50" })
                </td>
            </tr>
            <tr>
                <td style="text-align: right; width: 100px;">
                    角色状态：
                </td>
                <td>
                    @{
        var roleStstusList = new List<SelectListItem>();
        roleStstusList.Add(new SelectListItem() { Value = "1", Text = "启用" });
        roleStstusList.Add(new SelectListItem() { Value = "2", Text = "禁用" });
                        @Html.DropDownListFor(model => model.Status, roleStstusList);
                    }
                </td>
            </tr>
            <tr style="display: none;">
                <td style="width: 100px; text-align: right;">
                    角色类型：
                </td>
                <td>
                    @{
                                                                                    var roleTypeList = new List<SelectListItem>();
                                                                                    roleTypeList.Add(new SelectListItem() { Value = "-1", Text = "-请选择-" });
                        @Html.DropDownListFor(model => model.RoleType, roleTypeList, new { style = "Width: 200px;" });
                    }
                </td>
            </tr>
            <tr>
                <td style="text-align: right;" valign="top">
                    角色描述：
                </td>
                <td>
                    @Html.TextAreaFor(model => Model.Description, new { style = "Width: 400px; Height: 50px;" })
                </td>
            </tr>
        </table>
         
             
        @Html.Partial("_ToolBarPanel", dataConfigToolbar);
        <div style="width: 100%; height: 300px; overflow-y: scroll; margin-right: 4px">
            @Html.Partial("_RoleDBConfig", Model.RoleDBItems)
        </div>
    }
</div>
